import request from "@/utils/request";

/***
 * 关联客户列表
 *
 */
export const getCustomList = props => {
  return request({
    url: "/quote/budget/quotation/customAddress",
    method: "get",
    params: props
  });
};
/***
 * 创建预算报价
 *
 */
export const crateBudgetQuotation = props => {
  return request({
    url: "/quote/budget/quotation/crateBudgetQuotation",
    method: "post",
    data: props
  });
};
/***
 * 查询预算报价列表
 *
 */
export const budgetCustomerList = props => {
  return request({
    url: "/quote/budget/quotation/budgetCustomerList",
    method: "post",
    data: props
  });
};
/***
 * 查询预算报价列表-优化版，最近选择过得排在前面
 *
 */
export const budgetCustogetCustomerListByUseSortmerList = props => {
  return request({
    url: "/quote/budget/quotation/getCustomerListByUseSort",
    method: "get",
    params: props
  });
};

// ====================================================列表页============================================================
/**
 * 获取客户信息
 */
export const getCustomDetail = props => {
  return request({
    url: "/quote/budget/quotation/budgetCustomer/" + props.ysId + "/" + props.budgetId,
    method: "get"
  });
};

/**
 * 选择模板列表
 */
export const chooseTemplate = props => {
  return request({
    url: "/quote/budget/quotation/chooseTemplate",
    method: "post",
    data: props
  });
};

/**
 * 确认导入预算模板
 */
export const importBudgetQuotation = props => {
  return request({
    url: "/quote/budget/quotation/importBudgetQuotation",
    method: "post",
    data: props
  });
};
/**
 * 查询已导入的模板列表
 */
export const queryBudgetQuotationTemplateList = props => {
  return request({
    url: "/quote/budget/quotation/queryBudgetQuotationTemplateList",
    method: "post",
    data: props
  });
};
/**
 * 编辑导入的模板名称
 */
export const updateBudgetQuotationName = props => {
  return request({
    url: "/quote/budget/quotation/updateBudgetQuotationName",
    method: "post",
    data: props
  });
};
/**
 * 删除导入的模板
 */
export const delBudgetQuotation = props => {
  return request({
    url: "/quote/budget/quotation/delBudgetQuotation",
    method: "post",
    data: props
  });
};
/**
 * 复制导入的模板
 */
export const copyBudgetQuotation = props => {
  return request({
    url: "/quote/budget/quotation/copyBudgetQuotation",
    method: "post",
    data: props
  });
};

// ================================================指定模板下面的报价单明细=================================
/**
 * 查询指定模板下面的报价单明细
 */
export const getBudgetDetail = props => {
  return request({
    url: `/quote/customer/budget/detail/${props.budgetId}`,
    method: "get"
    // params: props
  });
};
/**
 * 编辑空间重命名
 */
export const spaceQueryUpdateName = props => {
  return request({
    url: "/quote/budget/quotation/SpaceQueryUpdateName",
    method: "post",
    data: props
  });
};
/**
 * 复制空间
 */
export const spaceQueryCopy = props => {
  return request({
    url: "/quote/budget/quotation/SpaceQueryCopy",
    method: "post",
    data: props
  });
};
/**
 * 删除空间
 */
export const spaceQueryDel = props => {
  return request({
    url: "/quote/budget/quotation/SpaceQueryDel",
    method: "post",
    data: props
  });
};
/**
 * 修改空间的工艺材料说明
 * 更新定额项目
 */
export const updateCustomerSpaceQuota = props => {
  return request({
    url: "/quote/customer/budget/updateCustomerSpaceQuota",
    method: "post",
    data: props
  });
};
/**
 * 删除工程项目
 */
export const deleteSpaceQuota = props => {
  return request({
    url: `/quote/customer/budget/deleteSpaceQuota/${props.contentId}`,
    method: "post"
  });
};

/**
 * 查询主材明细
 */
export const getMainProductsByContentId = props => {
  return request({
    url: `/quote/customer/budget/getMainProductsByContentId/${props.contentId}`,
    method: "get"
  });
};
/**
 * 查询辅材明细
 */
export const getAuxiliaryProductsByContentId = props => {
  return request({
    url: `/quote/customer/budget/getAuxiliaryProductsByContentId/${props.contentId}`,
    method: "get"
  });
};
/**
 * 查询人工明细
 */
export const getWorkerListByContentId = props => {
  return request({
    url: `/quote/customer/budget/getWorkerListByContentId/${props.contentId}`,
    method: "get"
  });
};
/**
 * 主材、辅材数量变更后的保存
 */
export const updateQuoteProductNum = props => {
  return request({
    url: "/quote/customer/budget/updateQuoteProductNum",
    method: "post",
    data: props
  });
};
/**
 * 人工数量变更后的保存
 */
export const updateQuoteWorkerNum = props => {
  return request({
    url: "/quote/customer/budget/updateQuoteWorkerNum",
    method: "post",
    data: props
  });
};
/**
 * 添加综合项
 */
export const comprehensiveAdd = props => {
  return request({
    url: "/quote/customer/budget/comprehensive/add",
    method: "post",
    data: props
  });
};
/**
 * 修改综合项
 */
export const comprehensiveUpd = props => {
  return request({
    url: "/quote/customer/budget/comprehensive/update",
    method: "post",
    data: props
  });
};
/**
 * 删除综合项
 */
export const comprehensiveDel = props => {
  return request({
    url: `/quote/customer/budget/comprehensive/delete/${props.itemId}`,
    method: "post",
    data: props
  });
};
/**
 * 修改房屋面积、管理费、税金费用
 */
export const updateBudgetQuotationFee = props => {
  return request({
    url: "/quote/budget/quotation/updateBudgetQuotationFee",
    method: "post",
    data: props
  });
};
/**
 * 查询预算汇总表单
 */
export const getSummary = props => {
  return request({
    url: `/quote/customer/budget/getSummary/${props.budgetId}`,
    method: "get"
  });
};
/**
 * 创建自定义定额-常规
 */
export const inventoryAddCustom = props => {
  return request({
    url: "/quote/budget/quotation/inventoryAddCustom",
    method: "post",
    data: props
  });
};
/**
 * 创建自定义定额-套餐
 */
export const packageAddCustom = props => {
  return request({
    url: "/quote/budget/quotation/packageAddCustom",
    method: "post",
    data: props
  });
};
/**
 * 修改空间备注
 */
export const updateCustomerSpaceRemark = props => {
  return request({
    url: "/quote/customer/budget/updateCustomerSpaceRemark",
    method: "post",
    data: props
  });
};
/**
 * 修改预算汇总备注
 */
export const updateCustomerBudgetRemark = props => {
  return request({
    url: "/quote/customer/budget/updateCustomerBudgetRemark",
    method: "post",
    data: props
  });
};

// ===========================================================选择商品=========================
/**
 * 查询分类
 */
export const categoryList = props => {
  return request({
    url: "/quote/shop/query/categoryList",
    method: "post",
    data: props
  });
};
/**
 * 条件内-通过分类id查询属性
 */
export const conditionInsideQuery = props => {
  return request({
    url: "/quote/budget/quotation/conditionInsideQuery",
    method: "post",
    data: props
  });
};

/**
 * 套餐报价-详情页-分类查询商品列表2
 */
export const pageByCombine = props => {
  return request({
    url: "/quote/shop/query/pageByCombine",
    method: "post",
    data: props
  });
};

/**
 * 分类查询商品列表
 */
export const getPage = props => {
  return request({
    url: "/quote/shop/query/page",
    method: "post",
    data: props
  });
};
/**
 * 组合条件-条件内-分类查询商品列表
 */
export const getPageV2 = props => {
  return request({
    url: "/quote/shop/query/pageV2",
    method: "post",
    data: props
  });
};
/**
 * 查询商品详情
 */
export const getProductDetail = props => {
  return request({
    url: "/quote/shop/query/product",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data: props
  });
};
/**
 * 保存临时商品
 */
export const saveTempProduct = props => {
  return request({
    url: "/quote/quotaTemplate/saveTempProduct",
    method: "post",
    data: props
  });
};
/**
 * 查询临时商品
 */
export const getTempProductList = props => {
  return request({
    url: "/quote/quotaTemplate/getTempProductList",
    method: "get",
    params: props
  });
};
/**
 * 删除临时商品
 */
export const delTempProduct = props => {
  return request({
    url: "/quote/quotaTemplate/delTempProduct",
    method: "post",
    data: props
  });
};

/**
 * 新增材料-常规
 */
export const inventoryAddMaterial = props => {
  return request({
    url: "/quote/budget/quotation/inventoryAddMaterial",
    method: "post",
    data: props
  });
};
/**
 * 新增材料-套餐
 */
export const packageAddMaterial = props => {
  return request({
    url: "/quote/budget/quotation/packageAddMaterial",
    method: "post",
    data: props
  });
};
/**
 * 属性查询
 */
export const queryStastsList = props => {
  return request({
    url: "/quote/shop/query/queryStastsList",
    method: "post",
    data: props
  });
};

// ===========================================================定额=================================
/**
 * 定额模板文件夹
 */
export const getfolderTree = props => {
  return request({
    url: "/quote/folder/tree",
    method: "get"
  });
};
/**
 * 根据文件夹id获取工程类型
 */
export const getProject = props => {
  return request({
    url: `/quote/project/getProject/${props.folderId}`,
    method: "get",
    params: { projectName: props.projectName }
  });
};
/**
 * 根据工程类型id获取定额列表
 */
export const getQuotaList = props => {
  return request({
    url: `/quote/quotaTemplate/list/${props.projectId}`,
    method: "get"
  });
};
/**
 * 根据工程类型id获取定额列表
 */
export const getQuotaList2 = props => {
  return request({
    url: `/quote/quotaTemplate/budgetList/${props.projectId}/${props.budgetId}`,
    method: "get"
  });
};
/**
 * 新增定额-常规
 */
export const inventoryAddQuota = props => {
  return request({
    url: "/quote/budget/quotation/inventoryAddQuota",
    method: "post",
    data: props
  });
};
/**
 * 新增定额-套餐
 */
export const packageAddQuota = props => {
  return request({
    url: "/quote/budget/quotation/packageAddQuota",
    method: "post",
    data: props
  });
};
/**
 * 查询定额主材辅材明细---固定商品
 */
export const quotaProductList = props => {
  return request({
    url: `/quote/quotaProduct/quotaProductList/${props.quotaId}`,
    method: "get",
    params: props
  });
};
/**
 * 查询定额主材辅材明细---组合条件
 */
export const quotaProductConditionList = props => {
  return request({
    url: `/quote/quotaProductCondition/quotaProductConditionList/${props.quotaId}`,
    method: "get",
    params: props
  });
};

/**
 * 查询定额人工明细
 */
export const quotaWorkerList = props => {
  return request({
    url: `/quote/quotaWorker/list/${props.quotaId}`,
    method: "get",
    params: props
  });
};

// ===============================================条件内、条件外=============================
/**
 * 组合条件-主材、辅材明细查询
 */
export const packageMainMaterial = props => {
  return request({
    url: "/quote/budget/quotation/packageMainMaterial",
    method: "post",
    data: props
  });
};
/**
 * 条件内、条件外-暂存商品sku
 */
export const saveCache = props => {
  return request({
    url: "/quote/quotaTemplate/saveCache",
    method: "post",
    data: props
  });
};
/**
 * 条件内、条件外-查询暂存商品sku
 */
export const queryCache = props => {
  return request({
    url: "/quote/quotaTemplate/queryCache",
    method: "post",
    data: props
  });
};
/**
 * 条件内、条件外-删除暂存商品sku
 */
export const delCache = props => {
  return request({
    url: "/quote/quotaTemplate/delCache",
    method: "post",
    data: props
  });
};

/**
 * 保存（根据组合条件增加）
 */
export const saveAddition = props => {
  return request({
    url: "/quote/budget/quotation/saveAddition",
    method: "post",
    data: props
  });
};
/**
 * 删除增项（根据组合条件增加）
 */
export const deleteAddition = props => {
  return request({
    url: "/quote/budget/quotation/deleteAddition",
    method: "post",
    data: props
  });
};
/**
 * 条件内-商品分类查询（根据组合条件增加）
 */
export const categoryListV2 = props => {
  return request({
    url: "/quote/shop/query/categoryListV2",
    method: "post",
    data: props
  });
};

export const getSpaceParamList = budgetId => {
  return request({
    url: `/quote/customer/budget/getSpaceParamList/${budgetId}`,
    method: "get"
  });
};

export const updateSpaceParam = data => {
  return request({
    url: "/quote/customer/budget/updateSpaceParam",
    method: "post",
    data: { params: data }
  });
};

export const getContractList = contractTypeId => {
  return request({
    url: `/contract/template/${contractTypeId}`,
    method: "get"
  });
};

export const getContractTypeList = () => {
  return request({
    url: "/quote/budget/template/contractTypeList",
    method: "get"
  });
};

export const getContractDetail = id => {
  return request({
    url: `/contract/info/manage/${id}`,
    method: "get"
  });
};

export const createContract = data => {
  return request({
    url: "/contract/info/manage/create",
    method: "post",
    data
  });
};

export const updateContract = data => {
  return request({
    url: "/contract/info/manage/update",
    method: "put",
    data
  });
};

export const updateConcludeInfo = data => {
  return request({
    url: "/quote/customer/budget/updateConcludeInfo",
    method: "post",
    data
  });
};

export const checkgrossProfitRate = data => {
  return request({
    url: "/quote/customer/budget/checkgrossProfitRate",
    method: "post",
    data
  });
};

export const commitApproval = data => {
  return request({
    url: "/quote/customer/budget/commitApproval",
    method: "post",
    data
  });
};

/**
 * 17.1.新增自定义材料
 * @param {*} data
 * @returns
 */
export const detailsAddMaterial = data => {
  return request({
    url: "/quote/budget/quotation/detailsAddMaterial",
    method: "post",
    data
  });
};

/**
 *
 */
export const getCustomerRemark = data => {
  return request({
    url: "/quote/shop/query/getCustomerRemark",
    method: "get",
    params: data
  });
};

/**删除报价客户信息 */
export const delBudgetCustomer = data => {
  return request({
    url: "/quote/budget/quotation/delBudgetCustomer",
    method: "post",
    data
  });
};

export const getBudgetExchangeDetail = budgetId => {
  return request({
    url: `/quote/customer/exchange/budget/getDetail/${budgetId}`,
    method: "get"
  });
};

export const getExchangeOrder = budgetId => {
  return request({
    url: `/quote/customer/exchange/budget/getExchangeOrder/${budgetId}`,
    method: "get"
  });
};

export const addBudgetExchangeProduct = data => {
  return request({
    url: "/quote/customer/exchange/budget/addExchangeProduct",
    method: "post",
    data
  });
};

export const deleteBudgetProduct = data => {
  return request({
    url: "/quote/customer/exchange/budget/deleteProduct",
    method: "post",
    data
  });
};

export const delExchangeProduct = data => {
  return request({
    url: "/quote/customer/exchange/budget/delExchangeProduct",
    method: "post",
    data
  });
};

export const addExchangeCustom = data => {
  return request({
    url: "/quote/customer/exchange/budget/inventoryAddCustom",
    method: "post",
    data
  });
};

export const updateProductDiscount = data => {
  return request({
    url: "/quote/customer/budget/updateProductDiscount",
    method: "post",
    data
  });
};

export const addExchangeQuota = data => {
  return request({
    url: "/quote/customer/exchange/budget/inventoryAddQuota",
    method: "post",
    data: { ...data, fromType: 1 }
  });
};

export const addExchangeMaterial = data => {
  return request({
    url: "/quote/customer/exchange/budget/inventoryAddMaterial",
    method: "post",
    data: { ...data, fromType: 1 }
  });
};

export const updateReturnOrderInfo = data => {
  return request({
    url: "/quote/customer/exchange/budget/updateReturnOrderInfo",
    method: "post",
    data: data
  });
};

export const updateReplacementOrder = data => {
  return request({
    url: "/quote/customer/exchange/budget/updateReplacementOrder",
    method: "post",
    data: data
  });
};

export const updateProductInfo = data => {
  return request({
    url: "/quote/customer/exchange/budget/updateProductInfo",
    method: "post",
    data: data
  });
};

export const replaceMaterial = data => {
  return request({
    url: "/quote/customer/exchange/budget/replaceMaterial",
    method: "post",
    data: data
  });
};

export const replaceQuota = data => {
  return request({
    url: "/quote/customer/exchange/budget/replaceQuota",
    method: "post",
    data: data
  });
};

export const deleteProduct = data => {
  return request({
    url: "/quote/customer/exchange/budget/deleteProduct",
    method: "post",
    data: data
  });
};

export const getHistoryExchangeOrder = exchangeBudgetId => {
  return request({
    url: `/quote/customer/exchange/budget/getHistoryExchangeOrder/${exchangeBudgetId}`,
    method: "get"
  });
};

export const rectificationTypeTree = (afterSalesType, isShow) => {
  return request({
    url: `/crm/reform/type/node/listTree?afterSalesType=${afterSalesType}&isShow=${isShow}`,
    method: "get"
  });
};

//整改变更模板
export const templateType = packageType => {
  return request({
    url: `/crm/reform/template/list?packageType=${packageType}`,
    method: "get"
  });
};

//整改变更原因分类树
export const serviceReasonTypeTree = afterSalesType => {
  return request({
    url: `/crm/serviceReason/node/listTree?afterSalesType=${afterSalesType}`,
    method: "get"
  });
};

/**
 * 整改标准
 */
export const rectificationStandard = reformTypeId => {
  return request({
    url: `/crm/reform/type/detail/${reformTypeId}`,
    method: "get"
  });
};

export const addreform = data => {
  return request({
    url: "/crm/reform/add",
    method: "post",
    data
  });
};

export const getPermission = budgetId => {
  return request({
    url: `/quote/customer/exchange/budget/getPermission?budgetId=${budgetId}`,
    method: "get"
  });
};

export const reformDetail = reformId => {
  return request({
    url: `/crm/reform/${reformId}`,
    method: "get"
  });
};

export const updatareform = (reformId, data) => {
  return request({
    url: `/crm/reform/edit/${reformId}`,
    method: "put",
    data
  });
};
export const getBuildConfig = customerId => {
  return request({
    url: `/contract/info/manage/getBuildConfig/${customerId}`,
    method: "get"
  });
};

/**
 * 修改报价单商品备注
 */
export const updateQuotaProductRemark = data => {
  return request({
    url: "/quote/budget/quotation/updateQuotaProductRemark",
    method: "post",
    data
  });
};

/**
 * 获取加入预算报价详情
 */
export const importSpaceDetails = data => {
  return request({
    url: "/quote/customer/budget/importSpaceDetails",
    method: "post",
    data
  });
};

/**
 *
 */

export const getProductByBudget = data => {
  return request({
    url: `/quote/customer/budget/getProduct/${data.contentId}`,
    method: "get"
  });
};
/*
 * 提交判断 是否为存采购
 * */
export const submitJudge = budgetId => {
  return request({
    url: `/quote/customer/budget/submitJudge/${budgetId}`,
    method: "get"
  });
};
// 省市区
export function getArea() {
  return request({
    url: "/dbo/region/tree"
  });
}
/**
 * 发起订单
 */
export const submitOrder = data => {
  return request({
    url: "/quote/customer/budget/initiateOrder",
    method: "post",
    data
  });
};
/**
 * 发起订单
 */
export const closeOrder = budgetId => {
  return request({
    url: `/quote/customer/budget/closeOrder/${budgetId}`,
    method: "post"
  });
};

/**
 * 分页商品查询new
 */
export const getSpListNewpage = data => {
  return request({
    url: "/quote/shop/query/newPage",
    method: "post",
    data
  });
};
/**
 * 预算报价导出
 */
export const exportPdf = data => {
  return request({
    url: "/quote/customer/budget/exportPdf",
    method: "post",
    data,
    responseType: "blob",
  });
};
/**
 * 预算报价导出详情
 */
export const exportDetail = budgetId => {
  return request({
    url: `/quote/customer/budget/exportDetail/${budgetId}`,
    method: "get"
  });
};
